<?php

/**
 * This is the model class for table "tbl_employeecontacts".
 *
 * The followings are the available columns in table 'tbl_employeecontacts':
 * @property integer $id
 * @property string $empno
 * @property string $contactname
 * @property string $email
 * @property string $phonework
 * @property string $workextention
 * @property string $phonehome
 * @property string $phonemobile
 * @property string $salutation
 * @property string $title
 */
class Employeecontacts extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Employeecontacts the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_employeecontacts';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('empno, contactname', 'required'),
			array('empno', 'length', 'max'=>4),
			array('contactname, title', 'length', 'max'=>50),
			array('email', 'length', 'max'=>1000),
			array('phonework, phonehome, phonemobile', 'length', 'max'=>12),
			array('workextention', 'length', 'max'=>6),
			array('salutation', 'length', 'max'=>40),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, empno, contactname, email, phonework, workextention, phonehome, phonemobile, salutation, title', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'empno' => 'Employee Number',
			'contactname' => 'Contact Name',
			'email' => 'Email',
			'phonework' => 'Phone Work',
			'workextention' => 'Work Extention',
			'phonehome' => 'Phone Home',
			'phonemobile' => 'Phone Mobile',
			'salutation' => 'Salutation',
			'title' => 'Title',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('empno',$this->empno,true);
		$criteria->compare('contactname',$this->contactname,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('phonework',$this->phonework,true);
		$criteria->compare('workextention',$this->workextention,true);
		$criteria->compare('phonehome',$this->phonehome,true);
		$criteria->compare('phonemobile',$this->phonemobile,true);
		$criteria->compare('salutation',$this->salutation,true);
		$criteria->compare('title',$this->title,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}